package com.project.easy.common.sequencer;

import java.util.UUID;

/**
 * @author GreatorMan.cool
 * @copyright: Copyright (c) 2020
 * @company: 扬起科技有限公司
 * @date 2021/10/23 22:36
 * @description: 随机函数
 */
public final class UUIdUtil extends AbstractSequencer {
    /**
     * 数据中心ID
     */
    private static Long dataCenterId;
    /**
     * 工作节点
     */
    private static Long workId;
    /**
     * UUID实例
     */
    private static AbstractSequencer uuIdUtil = null;
    static {
        uuIdUtil = new UUIdUtil(getWorkId(), getDataCenterId());
    }
    /**
     * 私有有构造方法
     */
    private UUIdUtil(Integer dataCenterId, Long workdId) {
        UUIdUtil.dataCenterId = Long.valueOf(dataCenterId);
        UUIdUtil.workId = workdId;
    }
    /**
     * 获取ID
     * @return 返回ID
     */
    public static String nextId() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
}
